import bsinRequest from '../utils/bsinRequest';

// 获取模板类型树
export const getModelTypeTree = (params: object) => {
  return bsinRequest('/getModelTypeTree', {
    serviceName: 'BsinAdminModelTypeService',
    methodName: 'getModelTypeTree',
    bizParams: {
      ...params,
    },
  });
};

// 请求模板列表
export const getPageListModel = (params: object) => {
  return bsinRequest('/getPageListModel', {
    serviceName: 'BsinAdminModelService',
    methodName: 'getPageListModel',
    bizParams: {
      ...params,
    },
  });
};

// 保存对应的模板信息
export const saveModel = (params: object) => {
  return bsinRequest('/saveModel', {
    serviceName: 'BsinAdminModelService',
    methodName: 'saveModel',
    bizParams: {
      ...params,
    },
  });
};

// 删除对应的模板信息
export const deleteModel = (params: object) => {
  return bsinRequest('/deleteModel', {
    serviceName: 'BsinAdminModelService',
    methodName: 'deleteModel',
    bizParams: {
      ...params,
    },
  });
};

// 保存对应的模板xml信息
export const saveModelXML = (params: object) => {
  return bsinRequest('/saveModelXML', {
    serviceName: 'BsinAdminModelService',
    methodName: 'saveModelXML',
    bizParams: {
      ...params,
    },
  });
};

// 部署/发布模型
export const deployModel = (params: object) => {
  return bsinRequest('/deployModel', {
    serviceName: 'BsinAdminModelService',
    methodName: 'deployModel',
    bizParams: {
      ...params,
    },
  });
};

// 获取xml
export const getModelById = (params: object) => {
  return bsinRequest('/getModelById', {
    serviceName: 'BsinAdminModelService',
    methodName: 'getModelById',
    bizParams: {
      ...params,
    },
  });
};

// 获取流程定义
export const getProcessDefinitionPageList = (params: object) => {
  return bsinRequest('/getProcessDefinitionPageList', {
    serviceName: 'BsinAdminProcessDefinitionService',
    methodName: 'getProcessDefinitionPageList',
    bizParams: {
      ...params,
    },
  });
};

// 获取流程定义
export const getProcessDefinitionStartForm = (params: object) => {
  return bsinRequest('/getProcessDefinitionStartForm', {
    serviceName: 'BsinFormRepositoryService',
    methodName: 'getProcessDefinitionStartForm',
    bizParams: {
      ...params,
    },
  });
};

// 根据流程定义ID启动流程
export const startProcessInstanceById = (params: object) => {
  return bsinRequest('/getProcessDefinitionStartForm', {
    serviceName: 'BsinRuntimeService',
    methodName: 'startProcessInstanceById',
    bizParams: {
      ...params,
    },
  });
};

// 根据启动表单启动流程
export const startProcessInstanceWithForm = (params: object) => {
  return bsinRequest('/startProcessInstanceWithForm', {
    serviceName: 'BsinRuntimeService',
    methodName: 'startProcessInstanceWithForm',
    bizParams: {
      ...params,
    },
  });
};
